import requests
import base64

headers = {
    "User-Agent": "yuanrenxue.project",
    "Cookie": "sessionid=pwin2ge9j7t9ttj5m15pjwar9m4sj9tc;",
}


# 主要难点是 m = btoa('yuanrenxue' + page)
def get_data(page):
    m = base64.b64encode(f'yuanrenxue{page}'.encode()).decode()
    url = f'https://match.yuanrenxue.com/api/match/12?page={page}&m={m}'
    return requests.get(url, headers=headers).json()


def main():
    value_list = []
    for page in range(1, 6):
        res = get_data(page)
        print("res==>", res)
        value_list += [v['value'] for v in res['data']]
    print(value_list)
    print(sum(value_list))


if __name__ == '__main__':
    main()
